package com.hzit.mmcb.core.controller.admin;

import com.hzit.common.result.PageResult;
import com.hzit.common.result.R;
import com.hzit.mmcb.core.pojo.entity.UserInfo;
import com.hzit.mmcb.core.pojo.vo.UserSearchVO;
import com.hzit.mmcb.core.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/core/userInfo")
@Api(tags = "后台会员信息管理")
public class AdminUserInfoController {
    @Autowired
    private UserInfoService userInfoService;

    @ApiOperation("查询会员列表 ")
    @PostMapping("/list/{page}/{pageSize}")
    public R list(@PathVariable @ApiParam(value = "页码",required = true) Integer page,
                  @PathVariable @ApiParam(value = "页的大小",required = true) Integer pageSize,
                  @RequestBody @ApiParam(value = "查询条件") UserSearchVO userSearch){

        PageResult<UserInfo> list = userInfoService.listPage(page,pageSize, userSearch);
        return R.ok().data("list",list);
    }

    @ApiOperation("修改状态信息")
    @GetMapping("/lock/{id}/{status}")
    public R lock(@PathVariable @ApiParam(value = "用户id",required = true) Long id,
                  @PathVariable @ApiParam(value = "用户id",required = true) Integer status){
        userInfoService.lock(id,status);
        return R.ok().message(status==1?"解锁成功":"加锁成功");
    }

}
